package com.muyu.danmo.controller;


import com.muyu.common.core.domain.Result;
import com.muyu.common.core.utils.poi.ExcelUtil;
import com.muyu.common.core.web.controller.BaseController;
import com.muyu.common.core.web.page.TableDataInfo;
import com.muyu.common.log.annotation.Log;
import com.muyu.common.log.enums.BusinessType;
import com.muyu.danmo.domain.DanmoArtDepartments;
import com.muyu.danmo.service.IDanmoArtDepartmentsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 院系设置Controller
 * 
 * @author yangle
 * @date 2025-05-30
 */
@RestController
@RequestMapping("/departments")
public class DanmoArtDepartmentsController extends BaseController
{
    @Autowired
    private IDanmoArtDepartmentsService danmoArtDepartmentsService;

    /**
     * 查询院系设置列表
     */
//    @RequiresPermissions("system:departments:list")
    @GetMapping("/list")
    public Result<TableDataInfo<DanmoArtDepartments>> list(DanmoArtDepartments danmoArtDepartments)
    {
        startPage();
        List<DanmoArtDepartments> list = danmoArtDepartmentsService.selectDanmoArtDepartmentsList(danmoArtDepartments);
        return getDataTable(list);
    }

    /**
     * 导出院系设置列表
     */
//    @RequiresPermissions("system:departments:export")
    @Log(title = "院系设置", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DanmoArtDepartments danmoArtDepartments)
    {
        List<DanmoArtDepartments> list = danmoArtDepartmentsService.selectDanmoArtDepartmentsList(danmoArtDepartments);
        ExcelUtil<DanmoArtDepartments> util = new ExcelUtil<DanmoArtDepartments>(DanmoArtDepartments.class);
        util.exportExcel(response, list, "院系设置数据");
    }

    /**
     * 获取院系设置详细信息
     */
//    @RequiresPermissions("system:departments:query")
    @GetMapping(value = "/{id}")
    public Result getInfo(@PathVariable("id") Long id)
    {
        return success(danmoArtDepartmentsService.selectDanmoArtDepartmentsById(id));
    }

    /**
     * 新增院系设置
     */
//    @RequiresPermissions("system:departments:add")
    @Log(title = "院系设置", businessType = BusinessType.INSERT)
    @PostMapping
    public Result add(@RequestBody DanmoArtDepartments danmoArtDepartments)
    {
        return toAjax(danmoArtDepartmentsService.insertDanmoArtDepartments(danmoArtDepartments));
    }

    /**
     * 修改院系设置
     */
//    @RequiresPermissions("system:departments:edit")
    @Log(title = "院系设置", businessType = BusinessType.UPDATE)
    @PutMapping
    public Result edit(@RequestBody DanmoArtDepartments danmoArtDepartments)
    {
        return toAjax(danmoArtDepartmentsService.updateDanmoArtDepartments(danmoArtDepartments));
    }

    /**
     * 删除院系设置
     */
//    @RequiresPermissions("system:departments:remove")
    @Log(title = "院系设置", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public Result remove(@PathVariable Long[] ids)
    {
        return toAjax(danmoArtDepartmentsService.deleteDanmoArtDepartmentsByIds(ids));
    }
}
